package mdFile

import "editor/constant"

func GetMDFileInfoByConfig(confArr []constant.MDFile, fileName, dirName string) (info *constant.MDFile) {
	if len(confArr) == 0 {
		return new(constant.MDFile)
	}

	for _, v := range confArr {
		if dirName == "" {
			if v.FileName == fileName {
				return &v
			}
		} else {
			if v.Name == dirName {
				for _, i := range v.ChildList {
					if i.FileName == fileName {
						return i
					}
				}
			}
		}
	}

	return new(constant.MDFile)
}
